package com.global.emc.spring.exception.handler;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.ModelAndView;

import com.global.emc.core.exception.IEMCException;

/**   
 *  
 * @Description:  [处理EMCException类型异常]   
 * @Author:       [Joly_Huang]   
 * @CreateDate:   [2014年2月20日 下午10:26:43]   
 * @UpdateUser:   [Joly_Huang]   
 * @UpdateDate:   [2014年2月20日 下午10:26:43]   
 * @UpdateRemark: [说明本次修改内容]  
 * @Version:      [v1.0] 
 *    
 */
public class EMCExceptionHandlerManager {
	
	private List<SpringMVCEMCExceptionHandler> emcExceptionHandlers;
	
	public List<SpringMVCEMCExceptionHandler> getEmcExceptionHandlers() {
		return emcExceptionHandlers;
	}
	public void setEmcExceptionHandlers(List<SpringMVCEMCExceptionHandler> emcExceptionHandlers) {
		this.emcExceptionHandlers = emcExceptionHandlers;
	}

	public void handlerException(HttpServletRequest request, HttpServletResponse response, Object handlerMethod, IEMCException emcException, ModelAndView modelAndView) {
		if(null == emcExceptionHandlers)
			return;
		
		for(SpringMVCEMCExceptionHandler  emcExceptionHandler : emcExceptionHandlers){
			if(emcExceptionHandler.supports(emcException)){
				emcExceptionHandler.handlerException(request, response, handlerMethod, emcException, modelAndView);
				return;
			}
		}
	}

}
